local c		= require "aoi.c"
local ct	= 0
function aoi_message(a,b)
	print(a,b)
	--ct=ct+1
end
local space = c.aoi_new(30)
--space:callback("aoi_message")

function print_aoi()

local tim1 = os.clock()
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>1",tim1)
local ret=space:message()
local tim2 = os.clock()
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>2",tim1-tim2)
for watcher,tbl in pairs(ret or {}) do
	print("R:",watcher,"#",#tbl)
	--print("R:",watcher,"#",table.unpack(tbl))
end
local tim3 = os.clock()
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>3",tim3-tim2)

end

local data={}
local tim1 = os.clock()
--[[
space:update(1,"wm",{["x"]=10,["y"]=10,["z"]=123,["dis"]=10})
space:update(2,"wm",{["x"]=10,["y"]=10,["z"]=123,["dis"]=10})

--space:update(1,"wm",{["x"]=10,["y"]=11,["z"]=123,["dis"]=10})

--print_aoi()

space:update(2,"m",{["x"]=11,["y"]=10,["z"]=123,["dis"]=10})
--space:update(2,"d",{["x"]=11,["y"]=10,["z"]=123,["dis"]=10})
space:update(2,"d")

print_aoi()
]]
for c=1,1000 do
	for i=1,2000 do
		space:update(i,"wm",{["x"]=math.random(30),["y"]=math.random(30),["z"]=123})
	end
end
local tim2 = os.clock()
print("tim cost1",tim2-tim1)
print_aoi()
local tbl=c.aoi_mem()
print("mem",tbl.count,tbl.max,tbl.current)
space:release()

local tbl=c.aoi_mem()
print("mem",tbl.count,tbl.max,tbl.current)
